/*
 * Copyright (C), 2018-2019, 深圳联合保理有限公司
 * FileName: SystemApiClientFallBack
 * Author:   xueliang.xiao
 * Date:     2019/10/25 16:12
 * @since 1.0.0
 */
package com.dome.order.feign.fallback;

import com.dome.order.entity.dto.OrderDto;
import com.dome.order.feign.OrderClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *
 * @author hz
 * FallbackFactory不能与FeignErrorDecoder（ErrorDecoder）一起用,使用FallbackFactory 则ErrorDecoder失效
 * @since 1.0.0
 */
@Slf4j
@Component
public class OrderClientFallBackFactory implements FallbackFactory<OrderClient> {

    @Override
    public OrderClient create(Throwable throwable) {
        return new OrderClient() {
            @Override
            public OrderDto selectById(Long id) {
                OrderDto dto=new OrderDto();
                dto.setOrderNo(id.toString());
                return dto;
            }
        };
    }
}